package com.stm.bi.web;

import com.stm.bi.dto.query.ProductStructQry;
import com.stm.bi.model.Chart;
import com.stm.bi.model.DatatablePage;
import com.stm.bi.service.ProductStructService;
import com.stm.framework.annotation.Module;
import com.stm.framework.annotation.RestApi;
import com.stm.framework.dto.Response;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author chenyingjun
 * @date 2023-05-09
 */
@RestController
@RequestMapping("/productStruct")
@Module("商品结构查询")
public class ProductStructController {
    @Resource
    private ProductStructService productStructService;


    @PostMapping(value = "/prodData/processChart")
    @RestApi(name = "商品结构推移-合计推移图", author = "zhouyuanpeng", idx = 1)
    public Response<Chart<List<List<Object>>>> selectChart(@RequestBody ProductStructQry productStructQry) {
        return productStructService.queryChart(productStructQry);
    }


    @PostMapping(value = "/prodData/table")
    @RestApi(name = "商品结构推移-推移表", author = "zhouyuanpeng", idx = 2)
    public Response<DatatablePage> selectTable(@RequestBody ProductStructQry productStructQry) {
        return productStructService.queryTable(productStructQry);
    }

    @PostMapping(value = "/prodData/export")
    @RestApi(name = "商品结构推移-导出", author = "zhouyuanpeng", idx = 3)
    public Response export(HttpServletResponse response, @RequestBody ProductStructQry reportQry) {
        return productStructService.export(response, reportQry);
    }

}
